package cn.iocoder.yudao.framework.tenant.core.aop;

import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

/**
 * @author ext.gouying3
 * @date 2025/7/28
 */
@Aspect
@Slf4j
public class TenantIgnoreAspect {



    @Around("@annotation(tenantIgnore)")
    public Object around(ProceedingJoinPoint joinPoint,TenantIgnore tenantIgnore) throws Throwable {
        boolean ignore = TenantContextHolder.isIgnore();
        try{
            TenantContextHolder.setIgnore(true);
            return joinPoint.proceed();
        }finally {
            TenantContextHolder.setIgnore(ignore);
        }
    }
}
